package com.example;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;


@SpringBootTest
public class SpringBootRedisTemplate {
    /*
    字符串型redis客户端操作器 可以与 本地redis相同
     */
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Test
    void get(){
        ValueOperations<String, String> stringStringValueOperations = stringRedisTemplate.opsForValue();
        String name2 = stringStringValueOperations.get("name2");
        System.out.println(name2);
    }

    @Test
    void update(){
        /*
        修改与set相同
         */
        ValueOperations<String, String> stringStringValueOperations = stringRedisTemplate.opsForValue();
        stringStringValueOperations.set("name2","itheima");
    }


}
